package com.acsior.hibernate.vo;

import static javax.persistence.InheritanceType.JOINED;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Inheritance;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import com.acsior.dac.impl.hibernate.vo.GeneratorKey;
import com.acsior.dac.impl.hibernate.vo.HibernateLastChangeVO;

/**
 * ServiceRequest entity. @author MyEclipse Persistence Tools <b><i>powered by
 * Belev</i></b>
 */
@Entity
@Table(name = "service_requests")
@Inheritance(strategy = JOINED)
@GeneratorKey(tableName = "service_requests")
public class ServiceRequestVO extends HibernateLastChangeVO {

	private static final long serialVersionUID = 2603577491845249047L;

	@Column(name = "accept_date", nullable = false, length = 23)
	private Date acceptDate;

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "accept_employee_id", nullable = false)
	private EmployeeVO acceptEmployee;

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "accept_structure_id", nullable = false)
	private StructureVO acceptStructure;

	@Column(name = "cancellation_request", nullable = false)
	private boolean cancellationRequest;

	/** датата на последна промяна на обекта */
	@Column(name = "last_change", nullable = false, length = 23)
	private Date lastChange;

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "nom_service_status_id", nullable = false)
	private NomServiceStatusVO nomServiceStatus;

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "postal_service_id", nullable = false)
	private PostalServiceVO postalService;

	@Column(name = "revision_request", nullable = false)
	private boolean revisionRequest;

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "serviceRequest")
	private List<ServiceLogVO> serviceLogs;

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "request")
	private List<ServicePriceVO> servicePrices;

	@Column(name = "status_date", nullable = false, length = 23)
	private Date statusDate;

	@Column(name = "uin", nullable = false)
	private Integer uin;

	/** default constructor */
	public ServiceRequestVO() {
		this.serviceLogs = new ArrayList<ServiceLogVO>();
		this.servicePrices = new ArrayList<ServicePriceVO>();
	}

	/** @return the acceptDate */
	public Date getAcceptDate() {
		return this.acceptDate;
	}

	/** @return the acceptEmployee */
	public EmployeeVO getAcceptEmployee() {
		return this.acceptEmployee;
	}

	/** @return the acceptStructure */
	public StructureVO getAcceptStructure() {
		return this.acceptStructure;
	}

	/** @return the lastChange */
	@Override
	public Date getLastChange() {
		return this.lastChange;
	}

	/** @return the nomServiceStatus */
	public NomServiceStatusVO getNomServiceStatus() {
		return this.nomServiceStatus;
	}

	/** @return the postalService */
	public PostalServiceVO getPostalService() {
		return this.postalService;
	}

	/** @return the serviceLogs */
	public List<ServiceLogVO> getServiceLogs() {
		return this.serviceLogs;
	}

	/** @return the servicePrices */
	public List<ServicePriceVO> getServicePrices() {
		return this.servicePrices;
	}

	/** @return the statusDate */
	public Date getStatusDate() {
		return this.statusDate;
	}

	/** @return the uin */
	public Integer getUin() {
		return this.uin;
	}

	/** @return the cancellationRequest */
	public boolean isCancellationRequest() {
		return this.cancellationRequest;
	}

	/** @return the revisionRequest */
	public boolean isRevisionRequest() {
		return this.revisionRequest;
	}

	/**
	 * @param acceptDate
	 *            the acceptDate to set
	 */
	public void setAcceptDate(Date acceptDate) {
		this.acceptDate = acceptDate;
	}

	/**
	 * @param acceptEmployee
	 *            the acceptEmployee to set
	 */
	public void setAcceptEmployee(EmployeeVO acceptEmployee) {
		this.acceptEmployee = acceptEmployee;
	}

	/**
	 * @param acceptStructure
	 *            the acceptStructure to set
	 */
	public void setAcceptStructure(StructureVO acceptStructure) {
		this.acceptStructure = acceptStructure;
	}

	/**
	 * @param cancellationRequest
	 *            the cancellationRequest to set
	 */
	public void setCancellationRequest(boolean cancellationRequest) {
		this.cancellationRequest = cancellationRequest;
	}

	/**
	 * @param lastChange
	 *            the lastChange to set
	 */
	@Override
	public void setLastChange(Date lastChange) {
		this.lastChange = lastChange;
	}

	/**
	 * @param nomServiceStatus
	 *            the nomServiceStatus to set
	 */
	public void setNomServiceStatus(NomServiceStatusVO nomServiceStatus) {
		this.nomServiceStatus = nomServiceStatus;
	}

	/**
	 * @param postalService
	 *            the postalService to set
	 */
	public void setPostalService(PostalServiceVO postalService) {
		this.postalService = postalService;
	}

	/**
	 * @param revisionRequest
	 *            the revisionRequest to set
	 */
	public void setRevisionRequest(boolean revisionRequest) {
		this.revisionRequest = revisionRequest;
	}

	/**
	 * @param serviceLogs
	 *            the serviceLogs to set
	 */
	public void setServiceLogs(List<ServiceLogVO> serviceLogs) {
		this.serviceLogs = serviceLogs;
	}

	/**
	 * @param servicePrices
	 *            the servicePrices to set
	 */
	public void setServicePrices(List<ServicePriceVO> servicePrices) {
		this.servicePrices = servicePrices;
	}

	/**
	 * @param statusDate
	 *            the statusDate to set
	 */
	public void setStatusDate(Date statusDate) {
		this.statusDate = statusDate;
	}

	/**
	 * @param uin
	 *            the uin to set
	 */
	public void setUin(Integer uin) {
		this.uin = uin;
	}
}